x,y=(input("Please input num of heads and legs (separated by space): ")).split(" ");
x=int(x);
y=int(y);
a=(4*x-y);
b=(y-2*x);

if a%2!=0 or b%2!=0 or a<0 or b<0:
    print("Invalid input");
else:
    print("chickens: ", a//2, ", rabbits: ", b//2);